//  定义AXI接口连接寄存器的各bit所表示的信号

#ifndef _REG_BITS_H_
#define _REG_BITS_H_

// AXI_Float_Point
#define ADDR_Float_Point_CTRL  0x41200000
#define ADDR_Float_Point_DATA  0x41200008

// AXI_GPIO_IN
//	PS reads register via a pointer pointing to ADDR_GPIO_IN
#define ADDR_GPIO_IN	       0x41210000
#define ADDR_PL_PS_DDR_CNT     0x41210008


// AXI_GPIO_OUT
//	PS writes register via a pointer pointing to ADDR_GPIO_OUT
#define ADDR_GPIO_OUT	       0x41220000

// GPIO_SPI_PS
#define ADDR_GPIO_SPI_PS_CTRL  0x41230000
#define ADDR_GPIO_SPI_PS_DATA  0x41230008


//================================================
//  GPIO: from PS to PL
//  #define ADDR_GPIO_OUT   0x41210000
//================================================

//  SPI-PL
#define BIT_SPI_RST	        0       //  触发PL端SPI模块发送数据至待配置芯片
#define BIT_SPI_CPHA	    1       //  设置待配置芯片的时序相位
#define BIT_SPI_CPOL        2       //  设置待配置芯片的时序极性
#define BIT_SPI_A2	        3       //  片选信号控制编码A2
#define BIT_SPI_A1	        4       //  片选信号控制编码A1
#define BIT_SPI_A0          5       //  片选信号控制编码A0

//  SPI-PS : PS端模拟的SPI通信,用于配置PL端的"配置寄存器"
#define BIT_SPI_PS_SCLK     6
#define BIT_SPI_PS_RST      7
#define BIT_SPI_PS_A2       8
#define BIT_SPI_PS_A1       9
#define BIT_SPI_PS_A0       10


#define BIT_156MHz_EN	    11      // 156MHz晶振使能
#define BIT_IS_MASTER       11      // 该GPIO引脚用于配置PL端是否为master


#define BIT_RESET_9508      12
#define BIT_SYNC_9508       13
#define BIT_READOUT_TRIG    14      // CCD读出触发信号
#define BIT_IDELAYCTRL_RST	15      // IDELAY复位信号

#define BIT_DDR_WR_EN       16      // DDR写入数据的是能信号

//  Readout
#define BIT_UPDATE_SPI_DATA1    17
#define BIT_UPDATE_SPI_DATA2    18
#define BIT_UPDATE_SPI_DATA3    19

// AFE_PD_CTL
#define BIT_AFE_PD_CTL          20

//******************************************************
//******************************************************
//  bits[31:21] 临时用来控制测试信号
#define BIT_IMGCLK_AD1_TGA      21
#define BIT_IMGCLK_AD2          22
#define BIT_IMGCLK_AD3          23
#define BIT_IMGCLK_AD4_TGD      24
#define BIT_BIAS_CTR            25
#define BIT_PS_DATA_SAVED       26  // 对应PL端ps_save_data_finished

// BIT_VTRANS_A0/1 共同控制A侧D侧的垂直转移驱动
#define BIT_VTRANS_A0           27
#define BIT_VTRANS_A1           28

//	Bonn-Shutter
#define BIT_SHUTTER             29
#define BIT_ADS5294_SYNC        30
#define BIT_10V_CTL             31


// ******************************************************************
// 以下定义不会真正使用，只是为了在编译为电路调试准备的测试代码不出现错误
#define BIT_CCD_TYPE		    27		// CCD类型选择
#define BIT_OPA862_EN		    28		// OPA862使能
#define BIT_RG_AD               33
#define BIT_PHI1                34
#define BIT_PHI2                35
#define BIT_PHI3                36
// ******************************************************************

//================================================
//  GPIO: from PL to PS
//  #define ADDR_GPIO_IN    0x41210000
//================================================
#define BIT_SPI_STATUS_ADS5294  0
#define BIT_SPI_STATUS_DACX0508 1
#define BIT_SPI_STATUS_DAISY    2
#define BIT_SPI_STATUS_AD9508   3
#define BIT_READOUT_DONE        4
#define BIT_SPI_DAISY_CFG_DONE  5
#define BIT_POWER_UP            6
#define BIT_IDELAYCTRL_RDY_X    7
#define BIT_IDELAYCTRL_RDY_Y    8

//	监测快门状态
#define BIT_SHUTTER_BLADE_A     9     
#define BIT_SHUTTER_BLADE_B     10
#define BIT_SHUTTER_ERROR       11

#define BIT_DDR_DATA_RDY        12
//================================================
// #define ADDR_Float_Point_ADDR   0x41220000
#define BIT_FLOAT_SPI_PS_SCLK   31
#define BIT_FLOAT_SPI_PS_RST    30
#define BIT_FLOAT_SPI_PS_A3     29
#define BIT_FLOAT_SPI_PS_A2     28
#define BIT_FLOAT_SPI_PS_A1     27
#define BIT_FLOAT_SPI_PS_A0     26

//================================================
// #define ADDR_GPIO_SPI_PS_CTRL    0x41230000
#define BIT_SPI_PS_SCLK_NEW     31
#define BIT_SPI_PS_RST_NEW      30
#define BIT_SPI_PS_A3_NEW       29
#define BIT_SPI_PS_A2_NEW       28
#define BIT_SPI_PS_A1_NEW       27
#define BIT_SPI_PS_A0_NEW       26


//================================================
// #define ADDR_GPIO_SPI_PS_DATA    0x41230008
#endif
